<template>
	<view>

	</view>
</template>

<script>
	import JSEncrypt from './jsencrypt.min.js';
	// 公钥key
	const publiukey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
	  '2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='
	// 私钥key
	const privatekey = 'MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8\n' +
	  'mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9p\n' +
	  'B6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue\n' +
	  '/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZ\n' +
	  'UBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6\n' +
	  'vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha\n' +
	  '4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3\n' +
	  'tTbklZkD2A=='
	export default {
		data() {
			return {

			}
		},
		methods: {

		},
		getRealLen: function(str) {
			return str.replace(/[^\x00-\xff]/g, '__').length;

		},
		setEncryptList: function(str, max) {
			var arr = []

			var s = str,
				reg = /.{40}/g,
				ppstr = s.match(reg);
			ppstr.push(s.substring(ppstr.join('').length));

			for (var nux = 0; nux < ppstr.length; nux++) {
				var Nax = this.getRealLen(ppstr[nux]);
				if (Nax > 116) {
					var list = this.setEncryptList(ppstr[nux], Nax)
					for (var nu = 0; nu < list.length; nu++) {
						arr.push(list[nu]);
					}
				} else {

					arr.push(this.setEncrypt(ppstr[nux]));
				}

			}
			return arr;
		},
		setEncrypt: function(data) {
			const encrypt = new JSEncrypt();
			encrypt.setPublicKey(publiukey);
			return encrypt.encrypt(data);
		},
		setLongEncrypt: function(data) {
			var s = data,
				reg = /.{116}/g,
				rs = s.match(reg);
			rs.push(s.substring(rs.join('').length));
			var arr = [];
			for (var n = 0; n < rs.length; n++) {
				var max = this.getRealLen(rs[n]);

				if (max > 116) {

					var list = this.setEncryptList(rs[n], max)
					for (var nu = 0; nu < list.length; nu++) {
						arr.push(list[nu]);
					}
				} else {

					arr.push(this.setEncrypt(rs[n]));
				}

			}
			return arr;
		},
		setDecryptArray: function(ArrayData) {
			var Decrypt = "";
			for (var n = 0; n < ArrayData.length; n++) {
				Decrypt = Decrypt + this.setDecrypt(privatekey, ArrayData[n]);
			}
			return Decrypt;
		},
		setDecrypt: function(data) {
			const encrypt = new JSEncrypt();
			encrypt.setPrivateKey(privatekey);

			return encrypt.decrypt(data);
		}
	}
</script>

<style>

</style>